package api

import (
	"github.com/gin-gonic/gin"
	"github.com/mojocn/base64Captcha"
	"net/http"
)

var store = base64Captcha.DefaultMemStore

func GetCaptcha_login(c *gin.Context) {

	driver := base64Captcha.NewDriverDigit(80, 240, 5, 0.7, 80)
	cp := base64Captcha.NewCaptcha(driver, store)
	id, b64, anwser, err := cp.Generate()

	//一个ip最多产生100个验证码,记录在redis,多的直接return no

	if err != nil {
		c.JSON(http.StatusInternalServerError, gin.H{
			"msg": "验证码生成错误",
		})
		return
	}

	c.JSON(http.StatusOK, gin.H{
		"captchaid": id,
		"picCode":   b64,
		"anwser":    anwser,
	})

}
func GetCaptcha_mail(c *gin.Context) {

}
func GetCaptcha_phone(c *gin.Context) {

}
